import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:nyh_motorcade_app/styles/colors.dart';
import 'package:nyh_motorcade_app/utils/string_utils.dart';

class VehicleIcon extends StatelessWidget {
  final String vehicleType;
  final String vehicleNumber;

  VehicleIcon(this.vehicleType, this.vehicleNumber);

  @override
  Widget build(BuildContext context) {
    return buildIconWidget();
  }

  Widget buildIconWidget() {
    if (vehicleType.isNotEmpty) {
      if (vehicleType == "MINI_CAR" || vehicleType == "MEDIUM_CAR" || vehicleType == "LARGE_CAR") {
        return Image.asset(
          "images/ic_automobile.png",
          fit: BoxFit.cover,
          height: 42.w,
          width: 42.w,
        );
      } else {
        return Image.asset(
          "images/ic_freight_car.png",
          fit: BoxFit.cover,
          height: 42.w,
          width: 42.w,
        );
      }
    } else {
      return Container(
        height: 42.w,
        width: 42.w,
        alignment: Alignment.center,
        decoration: BoxDecoration(
          color: Colours.color_theme,
          borderRadius: BorderRadius.circular(21.w),
          gradient: LinearGradient(
            begin: Alignment.topCenter,
            end: Alignment.bottomCenter,
            colors: [Colours.color_ffc700, Colours.color_theme],
          ),
        ),
        child: ClipOval(
          child: Text(
            StringUtils.getInitialText(vehicleNumber),
            style: TextStyle(
              color: Colours.color_white,
              fontSize: 24.sp,
            ),
          ),
        ),
      );
    }
  }
}
